<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>销售单子表</title>
    <% include("../layout/css.html"){} %>
</head>
<body>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card card-box-shadow">
        <div class="layui-card-header">销售单主表</div>
        <div class="layui-card-body">
            <form id="modelSellForm" lay-filter="modelSellForm" class="layui-form model-form">
                <input name="id" id="sellWithid" type="hidden" value="${sell.id}"/>
                <div class="layui-form-item layui-row">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">销售单号</label>
                        <div class="layui-input-block">
                            <input id="sellWithcode" name="code"  type="text" class="layui-input"  autocomplete="off"
                                   lay-verType="tips" lay-verify="" placeholder="请输入销售单号" value="${sell.code}"/>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">客户</label>
                        <div class="layui-input-block">
                            <input id="sellWithsupplier" name="supplier"  type="text" class="layui-input"  autocomplete="off"
                                   lay-verType="tips" lay-verify="" placeholder="请输入客户" value="${sell.supplier}"/>
                        </div>
                        <label class="pageSel" id="customSel">选择</label>
                    </div>
                </div>
                <div class="layui-form-item layui-row">
                    <!--<div class="layui-col-md6">
                        <label class="layui-form-label">仓库</label>
                        <div class="layui-input-block">
                            <input id="sellWithwarehouseName" name="warehouseName"  type="text" class="layui-input"  autocomplete="off"
                                   lay-verType="tips" lay-verify="" placeholder="请输入仓库" value="${sell.warehouseName}"/>
                        </div>
                    </div>-->
                    <div class="layui-col-md6">
                        <label class="layui-form-label">销售单日期</label>
                        <div class="layui-input-block">
                            <input id="sellWithsellTime" name="sellTime"  type="text" class="layui-input"  autocomplete="off" readonly
                                   lay-verType="tips" lay-verify="required" placeholder="请输入销售单日期" value="${sell.sellTime}"/>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">总金额</label>
                        <div class="layui-input-block">
                            <input id="sellWithtotal" name="total"  type="text" class="layui-input"  autocomplete="off" readonly
                                   lay-verType="tips" lay-verify="numberXZ" placeholder="请输入总金额" value="${sell.total}"/>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item layui-row">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">收款</label>
                        <div class="layui-input-block">
                            <select id="sellWithstate" name="state" lay-filter="sellWithstate" lay-verify="required" lay-search="">
                                <% for(dictionarydata in stateList) { %>
                                <option value="${dictionarydata.dictdata_name}">${dictionarydata.dictdata_name}</option>
                                <% } %>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">开票</label>
                        <div class="layui-input-block">
                            <select id="sellWithinvoice" name="invoice" lay-filter="sellWithinvoice" lay-verify="required" lay-search="">
                                <% for(dictionarydata in invoiceList) { %>
                                <option value="${dictionarydata.dictdata_name}">${dictionarydata.dictdata_name}</option>
                                <% } %>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item layui-row">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">备注</label>
                        <div class="layui-input-block">
                            <textarea name="remark" placeholder="请输入备注" class="layui-textarea"
                                      maxlength="255">${sell.remark}</textarea>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item text-right">
                    <button class="layui-btn layui-btn-primary" type="button" id="sellSonPageClose">关闭页面</button>
                    <button class="layui-btn" lay-filter="modelSellSubmit" lay-submit>保存</button>
                </div>
            </form>
        </div>
    </div>
    <div class="layui-card card-box-shadow">
        <div class="layui-card-header">销售单子表</div>
    	<div class="layui-card-body">
	        <div class="layui-form toolbar">
	            <div class="layui-form-item">
	                <div class="layui-inline layui-hide">
	                    <label class="layui-form-label w-auto">搜索：</label>
	                    <div class="layui-input-inline mr0">
	                        <input name="warehouseName" class="layui-input" type="text" placeholder="仓库,产品名称,规格"/>
	                    </div>
	                </div>
	                <div class="layui-inline">
	                    <button class="layui-btn icon-btn layui-hide" lay-filter="searchSubmit" lay-submit>
	                        <i class="layui-icon">&#xe615;</i>搜索
	                    </button>
	                    <% if(so.hasPermission("sellSon:add")){ %>
	                    <button id="btnAdd" class="layui-btn icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>
	                    <% } %>
	                </div>
	            </div>
	        </div>
        	<table class="layui-table" id="sellSonTable" lay-filter="sellSonTable"></table>
        </div>
    </div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="tableBar">
	<% if(so.hasPermission("sellSon:update")){ %>
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
    <% } %>
    <% if(so.hasPermission("sellSon:delete")){ %>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    <% } %>
</script>
<!-- 表单弹窗 -->
<script type="text/html" id="modelSellSon">
    <form id="modelSellSonForm" lay-filter="modelSellSonForm" class="layui-form model-form">
        <input name="id" id="id" type="hidden"/>
        <input name="companyId" type="hidden"/>
        <div class="layui-form-item layui-row">
            <div class="layui-col-md2">
                <label class="layui-form-label"></label>
                <div class="layui-input-block">
                </div>
                <label class="pageSel" id="productStorageSel">从库存选择产品</label>
            </div>
        </div>
        <div class="layui-form-item layui-row">
            <div class="layui-col-md4">
                <label class="layui-form-label">仓库</label>
                <div class="layui-input-block">
                    <input id="warehouseName" name="warehouseName"  type="text" class="layui-input"  autocomplete="off"
                    lay-verType="tips" lay-verify="required" placeholder="请输入仓库"/>
                </div>
                <label class="pageSel" id="warehouseNameSel">选择</label>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">当前库存</label>
                <div class="layui-input-block">
                    <input id="currentWarehouseNum" name="currentWarehouseNum"  type="text" class="layui-input"  autocomplete="off"
                           lay-verType="tips" lay-verify="" placeholder="请输入仓库" readonly/>
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-row">
            <div class="layui-col-md4">
                <label class="layui-form-label">产品</label>
                <div class="layui-input-block">
                    <input id="productName" name="productName"  type="text" class="layui-input"  autocomplete="off"
                           lay-verType="tips" lay-verify="required" placeholder="请输入产品"/>
                </div>
                <label class="pageSel" id="productSel">选择</label>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">规格</label>
                <div class="layui-input-block">
                    <input id="specification" name="specification"  type="text" class="layui-input"  autocomplete="off"
                           lay-verType="tips" lay-verify="required" placeholder="请输入规格"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">理论质量</label>
                <div class="layui-input-block">
                    <input id="liWeight" name="liWeight"  type="text" class="layui-input"  autocomplete="off"
                           lay-verType="tips" lay-verify="required|numberXZNotZero" placeholder="请输入重量"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-row">
            <div class="layui-col-md4">
                <label class="layui-form-label">负差</label>
                <div class="layui-input-block">
                    <input id="negative" name="negative"  type="number" class="layui-input"  autocomplete="off"
                           lay-verType="tips" lay-verify="required|numberX" placeholder="请输入负差"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">长度</label>
                <div class="layui-input-block">
                    <input id="lengths" name="lengths"  type="number" class="layui-input"  autocomplete="off"
                           lay-verType="tips" lay-verify="required|numberXZNotZero" placeholder="请输入长度"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">数量</label>
                <div class="layui-input-block">
                    <input id="num" name="num"  type="number" class="layui-input"  autocomplete="off"
                           lay-verType="tips" lay-verify="required|numberXZ" placeholder="请输入数量"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-row">
            <div class="layui-col-md4">
                <label class="layui-form-label">总重量</label>
                <div class="layui-input-block">
                    <input id="liTotalWeight" name="liTotalWeight"  type="text" class="layui-input"  autocomplete="off"
                           lay-verType="tips" lay-verify="required|numberXZ" placeholder="请输入总重量"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">销售重量</label>
                <div class="layui-input-block">
                    <input id="actualWeight" name="actualWeight"  type="text" class="layui-input"  autocomplete="off"
                           lay-verType="tips" lay-verify="" placeholder="请输入销售重量"/>
                </div>
            </div>

        </div>
        <div class="layui-form-item layui-row">
            <div class="layui-col-md4">
                <label class="layui-form-label">价格</label>
                <div class="layui-input-block">
                    <input id="price" name="price"  type="number" class="layui-input"  autocomplete="off"
                           lay-verType="tips" lay-verify="required|numberXZ" placeholder="请输入价格"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">总价</label>
                <div class="layui-input-block">
                    <input id="totalPrice" name="totalPrice"  type="text" class="layui-input"  autocomplete="off"
                           readonly lay-verType="tips" lay-verify="numberXZ" placeholder="请输入总价"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-row">
            <div class="layui-col-md4">
                <label class="layui-form-label">材质</label>
                <div class="layui-input-block">
                    <input id="model" name="model"  type="text" class="layui-input"  autocomplete="off"
                           lay-verType="tips" lay-verify="" placeholder="请输入材质"/>
                </div>
            </div>
            <div class="layui-col-md4">
                <label class="layui-form-label">产地</label>
                <div class="layui-input-block">
                    <input id="locality" name="locality"  type="text" class="layui-input"  autocomplete="off"
                           lay-verType="tips" lay-verify="" placeholder="请输入产地"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closePageDialog">取消</button>
            <button class="layui-btn" lay-filter="modelSellSonSubmit" lay-submit>保存</button>
        </div>
    </form>
</script>

<!-- js部分 -->
<% include("../layout/js.html"){} %>
<script type="text/javascript">
    layui.use(['layer', 'form', 'formX', 'table', 'util', 'admin',
        'zTree', 'tableX','laydate','index','excel','cascader'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var admin = layui.admin;
        var tableX = layui.tableX;
        var formX = layui.formX;
        var index = layui.index;
        var laydate = layui.laydate;
        var cascader = layui.cascader;
        var excel = layui.excel;//http://excel.wj2015.com

        //关闭当前页面
        $("#sellSonPageClose").click(function(){
            /*excel.exportExcel({
                sheet1: [{"data-field1": "ID", "data-field2": "用户名"},
                    {"data-field1": "20190510121452124560", "data-field2": "user001"}]
            }, '用户表' + new Date().toLocaleString() + '.xlsx', 'xlsx');*/
            top.layui.admin.closeThisTabs();
            //parent.layui.admin.events.closeThisTabs();
        });
        if("${sell.state}"!=""){
            $("#sellWithstate").val("${sell.state}");
        }
        if("${sell.invoice}"!=""){
            $("#sellWithinvoice").val("${sell.invoice}");
        }
        form.render('select');
        //选择客户
        $("#customSel").click(function(){
            var layindex_t1 = admin.open({
                type: 2,
                content:"${ctxPath}/relation/custom/listSel?" +
                    "name="+$("#sellWithsupplier").val(),
                maxmin: true,
                resize: true,
                area: ["1000px", "540px"],
                title: '请选择客户',
                success: function (layero, dIndex) {
                }
            });
            //layer.full(layindex_t1);
        });
        //选择仓库
        $("#warehouseSel").click(function(){
            var layindex_t1 = admin.open({
                type: 2,
                content:"${ctxPath}/storage/warehouse/listSel?id="
                    +"&name="+$("#sellWithwarehouseName").val(),
                maxmin: true,
                resize: true,
                area: ["1000px", "540px"],
                title: '请选择仓库',
                success: function (layero, dIndex) {
                }
            });
            //layer.full(layindex_t1);
        });
        top.customSel = function(data_custom){
            var t_data = data_custom[0];
            $("#sellWithsupplier").val(t_data.name);
            //$("#pName").val(t_data.name);
        }
        top.warehouseSel = function(data_sel){
            var t_data = data_sel[0];
            // $("#warehouseId",window.top.document).val(t_data.id);
            // $("#warehouseName",window.top.document).val(t_data.name);
            $("#sellWithwarehouseName").val(t_data.name);
        }
        // 表单提交事件
        var mainsubmit = "update";
        if($("#sellWithid").val()==""){
            mainsubmit = "add";
            $("#sellWithsellTime").val(dateToYMDHMS(new Date()));
            $("#sellWithtotal").val(0.0);
            $.ajax({
                url: '../system/sequence/code',// 这里写你要验证的地址哦。
                type:"post",
                async: true, // 使用同步的方法
                data: { //要提交到服务端验证的用户名
                    code: "sell"
                },
                dataType: 'html',
                success: function(data,status) { //栗子，返回的数据结果：{"rel":true,"message":"用户名已存在！"}
                    $("#sellWithcode").val(data);
                }
            });
        }
        form.on('submit(modelSellSubmit)', function (data) {
            layer.load(2);
            var keyid = 0;
            $.ajax({
                url: 'sell/'+mainsubmit,// 这里写你要验证的地址哦。
                type:"post",
                data: data.field,
                async:false,
                dataType: 'json',
                success: function(res) { //栗子，返回的数据结果：{"rel":true,"message":"用户名已存在！"}
                    layer.closeAll('loading');
                    keyid = res.keyid;
                    if (res.code == 200) {
                        //layer.close(dIndex);
                        top.sellTable();
                        if(mainsubmit=="add"){
                            $("#sellWithid").val(res.keyid);
                            mainsubmit = "update";
                            layer.msg(res.msg, {icon: 1, time: 1000}, function(){
                                index.openTab({
                                    title: '修改销售单',
                                    url: 'sell/sellSon?id='+ keyid,
                                    end: function() {
                                        //top.layui.admin.closeThisTabs();
                                        //parent.layui.admin.events.closeThisTabs();
                                        // table.reload('userTable');
                                    }
                                });
                                index.closeTab('sell/sellSon?id=');
                            });
                        } else {
                            layer.msg(res.msg, {icon: 1});
                        }
                        //insTb.reload();
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }
            });
            //$("button[lay-filter='modelsellSubmit']").attr("disabled","disabled");
            //setTimeout(function(){$("button[lay-filter='modelsellSubmit']").removeAttr("disabled");}, 1000 );
            return false;
        });
        //日期时间选择器
        // laydate.render({
        //     elem: '#sellWithsellTime'
        //     ,type: 'datetime'
        // });
        // 渲染表格
        var insTb = tableX.render({
            elem: '#sellSonTable'
            ,url: 'sellSon/list'
            ,page: true
            ,toolbar: true
            ,cellMinWidth: 100
            ,height:500
            ,cols: [[
                {type: 'numbers'}
                ,{field: "warehouseName", minWidth: "90", title: "仓库", sort: true, hide:false }
                ,{field: "productName", minWidth: "90", title: "产品", sort: true, hide:false }
                ,{field: "specification", minWidth: "90", title: "规格", sort: true, hide:false }
                ,{field: "lengths", minWidth: "90", title: "长度", sort: true, hide:false }
                ,{field: "negative", minWidth: "90", title: "负差", sort: true, hide:false }
                ,{field: "num", minWidth: "90", title: "数量", sort: true, hide:false }
                ,{field: "price", minWidth: "90", title: "价格", sort: true, hide:false }
                ,{field: "totalPrice", minWidth: "90", title: "总价", sort: true, hide:false }
                ,{field: "liWeight", minWidth: "90", title: "理论质量", sort: true, hide:false }
                ,{field: "liTotalWeight", minWidth: "90", title: "总重量", sort: true, hide:false }
                ,{field: "actualWeight", minWidth: "90", title: "销售重量", sort: true, hide:true }
                ,{field: "model", minWidth: "90", title: "材质", sort: true, hide:true }
                ,{field: "locality", minWidth: "90", title: "产地", sort: true, hide:true }
                ,{field: "createTime", minWidth: "90", title: "创建时间", sort: true, hide:true ,templet: function (d) {
                        return util.toDateString(d.createTime);
                    }
                }
                ,{field: "createUser", minWidth: "90", title: "创建人", sort: true, hide:true }
                ,{field: "updateTime", minWidth: "90", title: "更新时间", sort: true, hide:true ,templet: function (d) {
                        return util.toDateString(d.createTime);
                    }
                }
                ,{field: "updateUser", minWidth: "90", title: "更新人", sort: true, hide:true }
                ,{field: "del", minWidth: "90", title: "del(0正常 1删除)", sort: true, hide:true }
                ,{align: 'center', toolbar: '#tableBar', title: '操作', minWidth: 160, fixed: 'right'}
            ]]
            ,where:{"sellId":"${sell.id}"}
        });

        // 添加
        $('#btnAdd').click(function () {
            showEditModel();
        });

        // 搜索
        form.on('submit(searchSubmit)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}});
        });

        // 工具条点击事件
        table.on('tool(sellSonTable)', function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            if (layEvent === 'edit') { // 修改
                showEditModel(data);
            } else if (layEvent === 'del') { // 删除
                doDel(obj);
            }
        });

        // 删除
        function doDel(obj) {
            layer.confirm('确定要删除“' + obj.data.productName + '”销售单子表吗？', {
                shade: .1,
                skin: 'layui-layer-admin'
            }, function (i) {
                layer.close(i);
                layer.load(2);
                $.post('sellSon/delete', {
                    ids: obj.data.id
                }, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        insTb.reload();
                        calcTotalPrice();
                        top.productStorageTableReload();
                        //obj.del();
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'json');
            });
        }

        // 显示编辑弹窗
        function showEditModel(mSellSon) {
            if($("#sellWithid").val()==undefined || $("#sellWithid").val()==""){
                layer.msg("请先保存销售单主表!", {icon: 2});
                return false;
            }
            admin.open({
                type: 1,
                maxmin:true,
                closeBtn:1,
                resize: true,
				area:["1100px","500px"],
                title: (mSellSon ? '修改' : '添加') + '销售单子表',
                content: $('#modelSellSon').html(),
                success: function (layero, dIndex) {
                    var url = mSellSon ? 'sellSon/update' : 'sellSon/add';
                    form.val('modelSellSonForm', mSellSon);  // 回显数据
                    if(mSellSon){
                        $("#warehouseName").attr("readonly","readonly");
                        $("#productName").attr("readonly","readonly");
                        $("#specification").attr("readonly","readonly");
                        $("#liWeight").attr("readonly","readonly");
                        $("#warehouseNameSel").hide();
                        $("#productSel").hide();
                        $("#negative").attr("readonly","readonly");
                        $("#lengths").attr("readonly","readonly");
                    } else {
                        $("#negative").val("0");
                        $("#lengths").val("0");
                    }
                    var warehouseName2 = "", productName2="", specification2="", lengths2="", negative2="";
                    setInterval(getCurrentWarehouseNum,500);
                    function getCurrentWarehouseNum(){
                        if($("#warehouseName").val()!=""&&$("#productName").val()!=""
                            &&$("#specification").val()!=""&&$("#lengths").val()!=""){
                            if($("#warehouseName").val()!=warehouseName2 || $("#productName").val()!=productName2
                                || $("#specification").val()!=specification2 || $("#lengths").val()!=lengths2){
                                // console.log(warehouseName2 , $("#warehouseName").val());
                                // console.log(productName2 , $("#productName").val());
                                // console.log(specification2 , $("#specification").val());
                                // console.log(lengths2 , $("#lengths").val());
                                warehouseName2 = $("#warehouseName").val();
                                productName2 = $("#productName").val();
                                specification2 = $("#specification").val();
                                lengths2 = $("#lengths").val();
                                negative2 = $("#negative").val();
                                $.ajax({
                                    url: '../storage/productStorage/ajaxProductStorageNum',// 这里写你要验证的地址哦。
                                    type:"post",
                                    async: true, // 使用同步的方法
                                    data: { //要提交到服务端验证的用户名
                                        warehouseName: $("#warehouseName").val(),
                                        productName: $("#productName").val(),
                                        specification: $("#specification").val(),
                                        lengths: $("#lengths").val(),
                                        negative: $("#negative").val()
                                    },
                                    dataType: 'json',
                                    success: function(data,status) { //栗子，返回的数据结果：{"rel":true,"message":"用户名已存在！"}
                                        if(data.length>0){
                                            $("#currentWarehouseNum").val(data[0].num);
                                        } else {
                                            $("#currentWarehouseNum").val("0");
                                        }
                                    }
                                });
                            }
                        }
                    }

                    // 表单提交事件
                    form.on('submit(modelSellSonSubmit)', function (data) {
                        layer.load(2);
                        data.field.sellId=$("#sellWithid").val();
                        $.post(url, data.field, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.close(dIndex);
                                layer.msg(res.msg, {icon: 1});
                                insTb.reload();
                                calcTotalPrice();
                                top.productStorageTableReload();
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'json');
						$("button[lay-filter='modelSellSonSubmit']").attr("disabled","disabled");
                        setTimeout(function(){$("button[lay-filter='modelSellSonSubmit']").removeAttr("disabled");}, 1000 );
                        return false;
                    });
                    $("#productSel").click(function(){
                        var layindex_t1 = admin.open({
                            type: 2,
                            content:"${ctxPath}/storage/product/listSel?id="
                                +$("#productId").val()+"&name="+$("#productName").val()
                                +"&specification="+$("#specification").val()
                                +"&lengths="+$("#lengths").val(),
                            maxmin: true,
                            resize: true,
                            area: ["1000px", "540px"],
                            title: "请选择产品",
                            success: function (layero, dIndex) {
                            }
                        });
                        //layer.full(layindex_t1);
                    });
                    top.productSel = function(data_sel){
                        var t_data = data_sel[0];
                        $("#productName").val(t_data.name);
                        if(t_data.specification!=undefined && t_data.specification!=""){
                            $("#specification").val(t_data.specification);
                        }
                        if(t_data.liWeight!=undefined && t_data.liWeight!=""){
                            $("#liWeight").val(t_data.liWeight);
                        }
                    }
                    $("#warehouseNameSel").click(function(){
                        var layindex_t1 = admin.open({
                            type: 2,
                            content:"${ctxPath}/storage/warehouse/listSel?id="
                                +$("#warehouseId").val()+"&name="+$("#warehouseName").val(),
                            maxmin: true,
                            resize: true,
                            area: ["1000px", "540px"],
                            title: '请选择仓库',
                            success: function (layero, dIndex) {
                            }
                        });
                        //layer.full(layindex_t1);
                    });
                    $("#productStorageSel").click(function(){
                        var layindex_t1 = admin.open({
                            type: 2,
                            content:"${ctxPath}/storage/productStorage/listSel?warehouseName="
                                +$("#warehouseName").val()+"&productName="+$("#productName").val()
                                +"&specification="+$("#specification").val()
                                +"&lengths="+$("#lengths").val()+"&negative="+$("#negative").val(),
                            maxmin: true,
                            resize: true,
                            area: ["1000px", "540px"],
                            title: '请选择库存',
                            success: function (layero, dIndex) {
                            }
                        });
                        //layer.full(layindex_t1);
                    });
                    top.productStorageSel = function(data_sel){
                        var t_data = data_sel[0];
                        // $("#warehouseId",window.top.document).val(t_data.id);
                        // $("#warehouseName",window.top.document).val(t_data.name);
                        $("#warehouseName").val(t_data.warehouseName);
                        $("#productName").val(t_data.productName);
                        $("#specification").val(t_data.specification);
                        $("#lengths").val(t_data.lengths);
                        $("#liWeight").val(t_data.liWeight);
                        $("#negative").val(t_data.negative);
                    }
                    top.warehouseSel = function(data_sel){
                        var t_data = data_sel[0];
                        // $("#warehouseId",window.top.document).val(t_data.id);
                        // $("#warehouseName",window.top.document).val(t_data.name);
                        $("#warehouseName").val(t_data.name);
                    }
                    $("#liWeight,#num,#lengths").blur(function(){
                        if($("#liWeight").val()!="" && $("#num").val()!="" && $("#lengths").val()!="") {
                            var liTotalWeight = $("#liWeight").val()*$("#num").val()*$("#lengths").val()/1000;
                            $("#liTotalWeight").val(liTotalWeight.toFixed(3));
                            $("#actualWeight").val(liTotalWeight.toFixed(3));
                        }
                    });
                    $("#liWeight,#num,#lengths").change(function(){
                        if($("#liWeight").val()!="" && $("#num").val()!="" && $("#lengths").val()!="") {
                            var liTotalWeight = $("#liWeight").val()*$("#num").val()*$("#lengths").val()/1000;
                            $("#liTotalWeight").val(liTotalWeight.toFixed(3));
                            $("#actualWeight").val(liTotalWeight.toFixed(3));
                        }
                        $("#actualWeight,#price").blur();
                    });
                    $("#actualWeight,#price").blur(function(){
                        if($("#actualWeight").val()!=""&&$("#price").val()!=""){
                            var totalPrice2 = $("#actualWeight").val()*$("#price").val();
                            $("#totalPrice").val(totalPrice2.toFixed(2));
                        }
                    });
                    $("#actualWeight,#price").change(function(){
                        if($("#actualWeight").val()!=""&&$("#price").val()!=""){
                            var totalPrice2 = $("#actualWeight").val()*$("#price").val();
                            $("#totalPrice").val(totalPrice2.toFixed(2));
                        }
                    });
                    $("#liTotalWeight").blur(function(){
                        if($("#liTotalWeight").val()!=""){
                            $("#actualWeight").val($("#liTotalWeight").val());
                        }
                    });
                    $("#liTotalWeight").change(function(){
                        if($("#liTotalWeight").val()!=""){
                            $("#actualWeight").val($("#liTotalWeight").val());
                        }
                    });
                    top.sellTable();
                }
            });
        }
        function calcTotalPrice(){
            $.ajax({
                url: '../sell/sellSon/calcTotalPrice',// 这里写你要验证的地址哦。
                type:"post",
                async: true, // 使用同步的方法
                data: { //要提交到服务端验证的用户名
                    sellId: $("#sellWithid").val()
                },
                dataType: 'html',
                success: function(data,status) { //栗子，返回的数据结果：{"rel":true,"message":"用户名已存在！"}
                    $("#sellWithtotal").val(data);
                    top.sellTable();
                }
            });
        }
    });
</script>
</body>
</html>
